window.repeat = function (func, interval, repeat) {
    var _o = 0;
    var _id = window.setInterval(function () {
        _o += 1;
        if (_o >= repeat) {
            window.clearInterval(_id);
        } else {
            func();
        }
    }, interval);
}
window.delay = function (func, duration) {
    var _id = window.setTimeout(function () {
        window.clearTimeout(_id);
        func();
    }, duration);
}